﻿using System;
using TripLOA.WebService.Wrappers;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace TripLOA.WebService.Serializable
{
    /// <summary>
    /// Class that represents a WebService Message: a serializable list of messages
    /// </summary>
    [DataContract]
    public class WSMessage : WSObject
    {
        #region Costructors

        /// <summary>
        /// Parameterless Constructor. Set status to "fail"
        /// </summary>
        public WSMessage()
            : this("fail")
        { }

        /// <summary>
        /// Default Constructor. Set status to given value
        /// </summary>
        /// <param name="status">Status string, accepted values are "ok" or "fail"</param>
        public WSMessage(string status)
        {
            Status = status;
            Payload = new List<Message>();
        }


        /// <summary>
        /// Constructor. Add to the payload a Message object
        /// </summary>
        /// <param name="status">Status string, accepted values are "ok" or "fail"</param>
        /// <param name="m">Message object</param>
        public WSMessage(string status, Message m)
            : this(status)
        {
            Payload.Add(m);
        }

        #endregion

        #region Properties
        /// <summary>
        /// Payload contains a list of Message objects
        /// </summary>
        [DataMember]
        public List<Message> Payload;

        #endregion
    }
}
